﻿// JScript 文件


//填充县级行政单位列表
function fillCountySelect(event)
{
    $("#sltCounty").empty();
    var ProvinceId = $("#sltProvince").val();
    var ProvinceName = "全省（市、区）";
    if(typeof(ProvinceId) == "undefined") ProvinceId = "1";
    
    var strUrl = "Services/getDistrictList.aspx";
    $.get(strUrl,{ DISTID:ProvinceId,
                    TEMP:Math.random()
                  },
                  function(data){
                      var xmlDocument = data.documentElement;
                      var nodes = xmlDocument.getElementsByTagName("District");
                      var nCountys = nodes.length -1 ;

                      var countyOptionText = new Array();
                      var countyOptionValue = new Array();
                      countyOptionValue[0] = ProvinceId;
                      countyOptionText[0] = ProvinceName
                      for(var i=0; i<nCountys; i++)
                      {
                          countyOptionValue[i+1] = nodes[i].attributes[0].nodeValue;
                          countyOptionText[i+1] = nodes[i].attributes[1].nodeValue;
                      }
                      var countyOptions  = createOptions(countyOptionValue,countyOptionText);
                      for(var i = 0; i < nCountys + 1; i++)
                      {
                          document.getElementById("sltCounty").options.add(countyOptions[i]);
                      }
                      
                      //设置地图中心，随省区改变而改变
                      var lat = nodes[0].attributes[2].nodeValue;
                      var lng = nodes[0].attributes[3].nodeValue;
                      var centerPoint = new GLatLng(lat, lng);
                      gmap.setCenter(centerPoint, 5);
                  });

}

//确定所选取影像的类型，为多光谱还是高光谱 
function getImageType( )
{
    var ImageName = $("#ImageListSelect").val();
    
    var strUrl = "Services/getImagetype.aspx";
    $.get(strUrl,{ IMAGENAME:ImageName,
                   TEMP:Math.random()
                 },
                 function(data){
                       var xmlDocument = data.documentElement;
                       var nodes = xmlDocument.getElementsByTagName("Image");
                       var phoType = nodes[0].attributes[0].nodeValue;
                       
                       if(phoType == "hyper")
                       {
                            imageType = "hyper"; 
                            with($("#divtable")){
                                empty();
                            }
                            
                            //定义表格的列名称
                            var txtAgriTitle = document.createTextNode("农学参数");
                            var txtRSIndexTitle = document.createTextNode("多光谱植被指数");
                            var txtHyRSIndexTitle = document.createTextNode("高光谱指数");
                            
                            
                            //定义农学参数名称列表
                            var txtAgriArray = new Array( "病虫害指数(DI)","","","","","","","","","","","","","");
                            
                            //创建农学参数的textnode数组                                
                            var txtNodeAgriArray = createTextNode(txtAgriArray);                                
                            
                            //定义农学参数的CheckBox ID列表
                            var txtChkAgriArray = new Array("chkDiseaseIndex","","","","","","","","","","","","","");
                            
                            //定义农学参数的CheckBox数组                                
                            var chkAgriArray = createCheckboxs(txtChkAgriArray); 
                            
                            //将名称与checkbox连接成span元素
                            var spanAgriArray = new Array();
                            for(var i = 0; i < txtChkAgriArray.length; i++)
                            {
                                spanAgriArray[i] = document.createElement("span");
                                spanAgriArray[i].appendChild(chkAgriArray[i]);
                                spanAgriArray[i].appendChild(txtNodeAgriArray[i]);
                            }

                            //定义植被指数名称列表
//                            var txtRSIndexArray = new Array("NDWI", "NDWI2", "NDVI", "NRI",	"NSI", "WI", "G_SWIR", "G_SWIR2","EVI","RVI","ARVI","SAVI","MSAVI","DVI","RDVI");
                            var txtRSIndexArray = new Array("NDWI(叶面缺水指数)", "TVI(三角形植被指数)", "NDVI(归一化植被指数)", "NSI(Non-such Index)", "WI(温暖指数)", "NDGI(归一化差异绿度指数)", "GEMI(全球环境监测指数)","EVI(增强植被指数)","RVI(比值植被指数)","ARVI(大气阻抗植被指数)","SAVI(土壤调整植被指数)","MSAVI(改进调整植被指数)","DVI(差值植被指数)","RDVI(重归一化植被指数)");
                            
                            //创建植被指数的textnode数组       
                            var txtNodeRSIndexArray = createTextNode(txtRSIndexArray);                                
                            
                            //定义植被指数的CheckBox ID列表
                            var txtChkRSIndexArray = new Array("chkNDWI", "chkTVI", "chkNDVI", "chkNSI", "chkWI", "chkNDGI", "chkGEMI", "chkEVI","chkRVI","chkARVI","chkSAVI","chkMSAVI","chkDVI","chkRDVI");
                            
                            //定义植被指数的CheckBox数组                                
                            var chkRSIndexArray = createCheckboxs(txtChkRSIndexArray); 
                            
                            //将名称与checkbox连接成span元素
                            var spanRSIndexArray = new Array();
                            for(var i = 0; i < txtRSIndexArray.length; i++)
                            {
                                spanRSIndexArray[i] = document.createElement("span");
                                spanRSIndexArray[i].appendChild(chkRSIndexArray[i]);
                                spanRSIndexArray[i].appendChild(txtNodeRSIndexArray[i]);
                            }
                            
                            /////////////////////////////////////////////////////////////////////////////////////////////////////
                            var txtHyRSIndexArray = new Array("红边反射率", "吸收谷深度", "吸收谷波长", "吸收谷宽度",	"", "", "", "","","","","","","","");
                            
                            //创建植被指数的textnode数组       
                            var txtNodeHyRSIndexArray = createTextNode(txtHyRSIndexArray);                                
                            
                            //定义植被指数的CheckBox ID列表
                            var txtChkHyRSIndexArray = new Array("chkXREDEDGE", "chkXVALDEPTH", "chkXWAVELEN", "chkXWAVEWID",	"", "", "", "", "","","","","","","");
                            
                            //定义植被指数的CheckBox数组                                
                            var chkHyRSIndexArray = createCheckboxs(txtChkHyRSIndexArray); 
                            
                            //将名称与checkbox连接成span元素
                            var spanHyRSIndexArray = new Array();
                            for(var i = 0; i < txtHyRSIndexArray.length; i++)
                            {
                                spanHyRSIndexArray[i] = document.createElement("span");
                                spanHyRSIndexArray[i].appendChild(chkHyRSIndexArray[i]);
                                spanHyRSIndexArray[i].appendChild(txtNodeHyRSIndexArray[i]);
                            }       
                            
                            //创建绘制地图的button元素?????计算相关系数
                            var btnCalcuRxy = document.createElement("input");
                            btnCalcuRxy.type = "button";
                            btnCalcuRxy.value = "计算相关系数";
                            $(btnCalcuRxy).bind("click",function(){
                                var selectedAgriParams = "";
                                var selectedRSIndex = "";
                                for(var i = 0; i < chkRSIndexArray.length; i++)
                                {
                                    if(chkAgriArray[i].checked == true)
                                    {
                                        selectedAgriParams += chkAgriArray[i].id.substring(3) + ",";
                                    }
                                    if(chkRSIndexArray[i].checked == true)
                                    {
                                        selectedRSIndex += chkRSIndexArray[i].id.substring(3) + ",";
                                    }
                                    if(chkHyRSIndexArray[i].checked == true)
                                    {
                                        selectedRSIndex += chkHyRSIndexArray[i].id.substring(3) + ",";
                                    }

                                }
                                if(selectedAgriParams.length == 0) {alert("您没有选择农学参数，请您先选择至少一项农学参数！");return;}
                                if(selectedRSIndex.length == 0) {alert("您没有选择植被指数，请您先选择至少一项植被指数！");return;}
                                selectedAgriParams = selectedAgriParams.substring(0,selectedAgriParams.length - 1);
                                selectedRSIndex = selectedRSIndex.substring(0,selectedRSIndex.length - 1);
                                
                                var imageId = $("#ImageListSelect").val();
                                if(typeof(imageId)=="undefined") {alert("您没有选择用于建模的遥感影像，请您先从上一组菜单中选择一幅遥感影像！");return;}
                                
                                calculateRelatedCoefficient_Disease(selectedAgriParams,selectedRSIndex);
                            
                            });
                            
                            //将上面生成的元素组织成表格形式
                            var paramTableTitle = new Array(txtAgriTitle,txtRSIndexTitle,txtHyRSIndexTitle);
                            var paramTableValue = new Array(spanAgriArray,spanRSIndexArray,spanHyRSIndexArray);
                            var paramTable = new DataTable(paramTableTitle,paramTableValue,2);
                            
                             with($("#divtable")){
                                append(paramTable);
                                append(btnCalcuRxy);
                            }
                       }
                       else
                       {
                            imageType = "multi";
                            with($("#divtable")){
                                empty();
                             }
                             
                            //定义表格的列名称
                            var txtAgriTitle = document.createTextNode("农学参数");
                            var txtRSIndexTitle = document.createTextNode("植被指数");
                            
                            //定义农学参数名称列表
                            var txtAgriArray = new Array( "病虫害指数(DI)","","","","","","","","","","","","","");                             
                            //创建农学参数的textnode数组                                
                            var txtNodeAgriArray = createTextNode(txtAgriArray);                                
                            
                            //定义农学参数的CheckBox ID列表
                            var txtChkAgriArray = new Array("chkDiseaseIndex","","","","","","","","","","","","","");
                            //定义农学参数的CheckBox数组                                
                            var chkAgriArray = createCheckboxs(txtChkAgriArray);     
                            //将名称与checkbox连接成span元素
                            var spanAgriArray = new Array();
                            for(var i = 0; i < txtChkAgriArray.length; i++)
                            {
                                spanAgriArray[i] = document.createElement("span");
                                spanAgriArray[i].appendChild(chkAgriArray[i]);
                                spanAgriArray[i].appendChild(txtNodeAgriArray[i]);
                            }
                            //定义植被指数名称列表
//                            var txtRSIndexArray = new Array("NDWI", "NDWI2", "NDVI", "NRI",	"NSI", "WI", "G_SWIR", "G_SWIR2","EVI","RVI","ARVI","SAVI","MSAVI","DVI","RDVI");
                            //定义植被指数名称列表
                            var txtRSIndexArray = new Array("NDWI(叶面缺水指数)", "TVI(三角形植被指数)", "NDVI(归一化植被指数)", "NSI(Non-such Index)", "WI(温暖指数)", "NDGI(归一化差异绿度指数)", "GEMI(全球环境监测指数)","EVI(增强植被指数)","RVI(比值植被指数)","ARVI(大气阻抗植被指数)","SAVI(土壤调整植被指数)","MSAVI(改进调整植被指数)","DVI(差值植被指数)","RDVI(重归一化植被指数)");
                            
                            //创建植被指数的textnode数组       
                            var txtNodeRSIndexArray = createTextNode(txtRSIndexArray);                                
                            
                            //定义植被指数的CheckBox ID列表
                            var txtChkRSIndexArray = new Array("chkNDWI", "chkTVI", "chkNDVI", "chkNSI", "chkWI", "chkNDGI", "chkGEMI", "chkEVI","chkRVI","chkARVI","chkSAVI","chkMSAVI","chkDVI","chkRDVI");
 
                            //定义植被指数的CheckBox数组                                
                            var chkRSIndexArray = createCheckboxs(txtChkRSIndexArray); 
                            
                            //将名称与checkbox连接成span元素
                            var spanRSIndexArray = new Array();
                            for(var i = 0; i < txtRSIndexArray.length; i++)
                            {
                                spanRSIndexArray[i] = document.createElement("span");
                                spanRSIndexArray[i].appendChild(chkRSIndexArray[i]);
                                spanRSIndexArray[i].appendChild(txtNodeRSIndexArray[i]);
                            }
                            //创建绘制地图的button元素
                            var btnCalcuRxy = document.createElement("input");
                            btnCalcuRxy.type = "button";
                            btnCalcuRxy.value = "计算相关系数";
                            $(btnCalcuRxy).bind("click",function(){
                                var selectedAgriParams = "";
                                var selectedRSIndex = "";
                                for(var i = 0; i < chkRSIndexArray.length; i++)
                                {
                                    if(chkAgriArray[i].checked == true)
                                    {
                                        selectedAgriParams += chkAgriArray[i].id.substring(3) + ",";
                                    }
                                    if(chkRSIndexArray[i].checked == true)
                                    {
                                        selectedRSIndex += chkRSIndexArray[i].id.substring(3) + ",";
                                    }

                                }
                                if(selectedAgriParams.length == 0) {alert("您没有选择农学参数，请您先选择至少一项农学参数！");return;}
                                if(selectedRSIndex.length == 0) {alert("您没有选择植被指数，请您先选择至少一项植被指数！");return;}
                                selectedAgriParams = selectedAgriParams.substring(0,selectedAgriParams.length - 1);
                                selectedRSIndex = selectedRSIndex.substring(0,selectedRSIndex.length - 1);
                                
                                var imageId = $("#ImageListSelect").val();
                                if(typeof(imageId)=="undefined") {alert("您没有选择用于建模的遥感影像，请您先从上一组菜单中选择一幅遥感影像！");return;}
                                
                                calculateRelatedCoefficient_Disease(selectedAgriParams,selectedRSIndex);
                            
                            });    

                            //将上面生成的元素组织成表格形式
                            var paramTableTitle = new Array(txtAgriTitle,txtRSIndexTitle);
                            var paramTableValue = new Array(spanAgriArray,spanRSIndexArray);
                            var paramTable = new DataTable(paramTableTitle,paramTableValue,2);
                        
                        
                        //将表格和button添加到div
                        with($("#divtable")){
                                append(paramTable);
                                append(btnCalcuRxy);
                            }
                       }
                     
                 });           
}


//计算相关系数
//参数modelType，以确定要显示的列头
//selectedAgriParamList,selectedRSIndexList,modelType
//modelType:grow是长势，列头是农学参数；rs是单产，列头是单产,quality是品质预报，列头是品质指数,Rsquality为品质遥感监测，列头是品质
function calculateRelatedCoefficient()
{
    var strUrl = "Services/getCorrelationCoefficient.aspx";
    var imageId = $("#ImageListSelect").val();
    showWaitImage();
    
    var selectedAgriParamList=arguments[0];
    var selectedRSIndexList=arguments[1];
    var diseaseType=arguments[2];    
    
    if(gMapListen)
    {
        removeListener();
    }

    document.getElementById("mdiv").style.visibility="hidden";
    
    if(arguments.length==3)
    {
            $.get(strUrl,{  IMAGEID:imageId,
                    AGRILIST:selectedAgriParamList,
                    RSLIST:selectedRSIndexList,
                    TYPE:diseaseType,
                    TMP:Math.random()
                 },
                 function(data){
                    var xmlDocument = data.documentElement;
                    var nodes = xmlDocument.getElementsByTagName("Rxy");
                    var CoefficientPairCount = nodes.length;//xmlDocument.childNodes.length;
                    
                    var agriArray = new Array();                    
                    var rsArray = new Array();
                    var rArray = new Array();
                    var radioArray = new Array();
                    for(var i = 0; i < CoefficientPairCount; i++)
                    {
                        agriArray[i] = document.createTextNode(nodes[i].attributes[0].nodeValue);                        
                        rsArray[i] = document.createTextNode(nodes[i].attributes[1].nodeValue);
                        rArray[i] = document.createTextNode(nodes[i].attributes[2].nodeValue);
                        radioArray[i] = document.createElement("input");
                        radioArray[i].type = "radio";
                        radioArray[i].id = nodes[i].attributes[0].nodeValue + "-" + nodes[i].attributes[1].nodeValue;
                        radioArray[i].name = "RelatedCoefficient";
                        $(radioArray[i]).bind("click",{id: radioArray[i].id}, function(event)
                        {
                            for(var j = 0; j < CoefficientPairCount; j++)
                            {
                                $(radioArray[j]).attr("checked",false); 
                            }
                            eval($("#" + event.data.id)).attr("checked",true);
                        });
                        
                    }
                    var tableTitleNames;
                   
//*******************灾害监测--旱灾*****************
                    if(diseaseType=="drought")
                    {
                        tableTitleNames = new Array("农学参数","旱情指数","相关系数","选择");
                        var tableTitles = createTextNode(tableTitleNames);
                        var tableValues = new Array(agriArray,rsArray,rArray,radioArray);
                        
                        var RTable = new DataTable(tableTitles,tableValues,2);
                        
                        var divTable = document.createElement("div");
                        divTable.className = "resultTable";
                        divTable.appendChild(RTable);
                        $("#infoTable").empty();
                        

                        document.getElementById("infoTable").appendChild(divTable);
                        document.getElementById("infoTable").style.visibility = "visible";
                        document.getElementById("DivMenuControl").style.visibility = "visible";
                        //$("#forDatacache").data("saved","grow");
                    }
                   
                    hideWaitImage();
                    
                });
    }   
}


//求解模型参数
function resolveModelParam(event)
{
    var strUrl = "Services/getCorrelationCoefficient.aspx";
    var imageId = $("#ImageListSelect").val();

    if(gMapListen)
    {
        removeListener();
    }

    document.getElementById("mdiv").style.visibility="hidden";
    
    var SelectedRadioId = "";
    var RadioArray = $("input[type = 'radio']");
    for (var i = 0; i < RadioArray.length; i++)
    {
        if($(RadioArray[i]).attr("checked") == true)
        {
            SelectedRadioId = $(RadioArray[i]).attr("id");
            if (SelectedRadioId.indexOf("-") > -1)
                break;
        }
    }
    var SelectedRS=SelectedRadioId.substring(SelectedRadioId.indexOf("-")+1);
    if(SelectedRadioId.length == 0 || SelectedRadioId.indexOf("-") == -1)//"-"or"_"ljy?
    {
        alert("您还没有选择用于反算模型的农学参数—植被指数序列，请您在下方的表格中选取！");
        return;
        
    }
    var paramArray = SelectedRadioId.split('-');
    
    var strUrl ="Services/getModelParam.aspx";
    //此参数传递到页面类后，用作判断当前计算的模型类型，从id为forDatacache的div中取值，使用JQuery的data()方法，存取的变量是calculateType
    var type=$("#forDatacache").data("calculateType");
    
    $.get(strUrl,{  IMAGEID:imageId,
                    AGRI:paramArray[0],
                    RSINDEX:paramArray[1],
                    RSINDEX1:paramArray[2],
                    TYPE:type,
                    TEMP:Math.random()
                 },function(data){
                    var xmlDocument = data.documentElement;
                    var nodes = xmlDocument.getElementsByTagName("Param");
                    
                    var ParamA_Liner = nodes[0].attributes[0].nodeValue;
                    var ParamB_Liner = nodes[0].attributes[1].nodeValue;
                    var ParamR_Liner = nodes[0].attributes[2].nodeValue;
                    var ParamA_Exp = nodes[1].attributes[0].nodeValue;
                    var ParamB_Exp = nodes[1].attributes[1].nodeValue;
                    var ParamR_Exp = nodes[1].attributes[2].nodeValue;
                    var ParamA_Log = nodes[2].attributes[0].nodeValue;
                    var ParamB_Log = nodes[2].attributes[1].nodeValue;
                    var ParamR_Log = nodes[2].attributes[2].nodeValue;
                    
                    var txtModelLine = "";
                    var txtModelExp = "";
                    var txtModelLn = "";
                    
                    if(ParamB_Liner >= 0)
                    {  txtModelLine = "Y = " + ParamA_Liner + "+" + ParamB_Liner+ "*X";  }
                    else
                    {  txtModelLine = "Y = " + ParamA_Liner + "" + ParamB_Liner+ "*X";  }
                    $("#txtLine").val(txtModelLine);
                    $("#txtLineR").val(ParamR_Liner);
                    if(ParamB_Exp >= 0)
                    {  txtModelExp = "Y = " + ParamA_Exp + "+" + ParamB_Exp + "*Exp(X)";  }
                    else
                    {  txtModelExp = "Y = " + ParamA_Exp + "" + ParamB_Exp + "*Exp(X)";  }
                    $("#txtExp").val(txtModelExp);
                    $("#txtExpR").val(ParamR_Exp);
                    if(ParamB_Log >= 0)
                    {  txtModelLn = "Y = " + ParamA_Log + "+" + ParamB_Log + "*Ln(X)"; }
                    else
                    {  txtModelLn = "Y = " + ParamA_Log + "" + ParamB_Log + "*Ln(X)";  }                    
                    $("#txtLn").val(txtModelLn);
                    $("#txtLnR").val(ParamR_Log);
                    
             });

 }
    


//*********************灾害监测-病虫害***************
//计算植被指数
function calculateRSIndex_disease()
{    
    var imageId=$("#ImageListSelect").val();
    var blockSize = $("#BlockSizeSelect").val();  
    var rootId="";
    var distId="";
    rootId=$("#sltProvince").val();
    distId=$("#sltCounty").val();

    showWaitImage();
    
//调用 "services/getRSIndex_disease.aspx"进行计算
     var strURL = "services/getRSIndex_disease.aspx";
     $.get(strURL,{IMAGEID:imageId,
                   BLOCKSIZE:blockSize,
                   RID:rootId,
                   DID:distId,
                   IMAGETYPE:imageType,
                   TMP:Math.random()
                  },
                  function(data){ 
                  //读取xml文档
                  var xmlDocument = data.documentElement;
                  var nodes = xmlDocument.getElementsByTagName("Parcel");
                  var pointNumber = nodes.length;
                 
                  if (pointNumber == 0){
                    alert("植被指数计算过程出错，请您检查网络连接或者重新计算！");
                    return;
                  }
                  else
                  {
                     //标注样点于图上，并显示表格
                     if(imageType == "hyper")
                     {
                        markerSampleRSPoints_HyperDisease(xmlDocument)
                     }
                     else
                     {
                        markerSampleRSPoints_disease(xmlDocument);
                     }
                  }        
     });
}


//计算相关系数
function calculateRelatedCoefficient_Disease()
{
    var strUrl = "Services/getCorrelationCoefficient.aspx";
    var imageId = $("#ImageListSelect").val();
    showWaitImage();
    
    var selectedAgriParamList = arguments[0]; 
    var selectedRSIndexList = arguments[1];
    var diseaseType = "disease";
    
    $.get(strUrl,{  IMAGEID:imageId,
                    AGRILIST:selectedAgriParamList,
                    RSLIST:selectedRSIndexList,
                    TYPE:diseaseType,
                    TMP:Math.random()
                 },
                 function(data){
                
                    var xmlDocument = data.documentElement;
                    var nodes = xmlDocument.getElementsByTagName("Rxy");
                    var CoefficientPairCount = nodes.length;
                    
                    var agriArray = new Array();
                    var rsArray = new Array();
                    var rArray = new Array();
                    var radioArray = new Array();
                    for(var i = 0; i < CoefficientPairCount; i++)
                    {
                        agriArray[i] = document.createTextNode(nodes[i].attributes[0].nodeValue);
                        rsArray[i] = document.createTextNode(nodes[i].attributes[1].nodeValue);
                        rArray[i] = document.createTextNode(nodes[i].attributes[2].nodeValue);
                        radioArray[i] = document.createElement("input");
                        radioArray[i].type = "radio";
                        radioArray[i].id = nodes[i].attributes[0].nodeValue + "-" + nodes[i].attributes[1].nodeValue;
                        radioArray[i].name = "RelatedCoefficient";
                        $(radioArray[i]).bind("click",{id: radioArray[i].id}, function(event)
                        {
                            for(var j = 0; j < CoefficientPairCount; j++)
                            {
                                $(radioArray[j]).attr("checked",false); 
                            }
                            eval($("#" + event.data.id)).attr("checked",true);
                        });
                    }

                    var tableTitleNames = new Array("农学参数","植被指数","相关系数","选择");
                    var tableTitles = createTextNode(tableTitleNames);
                    var tableValues = new Array(agriArray,rsArray,rArray,radioArray);
                    
                    var RTable = new DataTable(tableTitles,tableValues,2);
                    
                    var divTable = document.createElement("div");
                    divTable.className = "resultTable";
                    divTable.appendChild(RTable);
                    $("#infoTable").empty();

                    document.getElementById("infoTable").appendChild(divTable);
                    document.getElementById("infoTable").style.visibility = "visible";
                    document.getElementById("DivMenuControl").style.visibility = "visible";
                    
                    hideWaitImage();
    });
   
}

//求解模型参数
function resolveModelParam_Disease(event)
{
    var imageId = $("#ImageListSelect").val();
    if(gMapListen) removeListener();

    document.getElementById("mdiv").style.visibility="hidden";

    var SelectedRadioId = "";
    var RadioArray = $("input[type = 'radio']");
    for (var i = 0; i < RadioArray.length; i++)
    {
        if($(RadioArray[i]).attr("checked") == true)
        {
            SelectedRadioId = $(RadioArray[i]).attr("id");
            if (SelectedRadioId.indexOf("-") > -1)
                break;
        }
    }
    
    if(SelectedRadioId.length == 0 || SelectedRadioId.indexOf("-") == -1)
    {
        alert("您还没有选择用于反算模型的农学参数—植被指数序列，请您在下方的表格中选取！");
        return;
        
    }
           
    var paramArray = SelectedRadioId.split('-');
    
    var strUrl ="Services/getModelParam_Disease.aspx";
    $.get(strUrl,{  IMAGEID:imageId,
                    AGRI:paramArray[0],
                    RSINDEX:paramArray[1],
                    TEMP:Math.random()
                 },function(data){
                    var xmlDocument = data.documentElement;
                    var nodes = xmlDocument.getElementsByTagName("Param");
                    
                    var ParamA_Liner = nodes[0].attributes[0].nodeValue;
                    var ParamB_Liner = nodes[0].attributes[1].nodeValue;
                    var ParamR_Liner = nodes[0].attributes[2].nodeValue;
                    var ParamA_Exp = nodes[1].attributes[0].nodeValue;
                    var ParamB_Exp = nodes[1].attributes[1].nodeValue;
                    var ParamR_Exp = nodes[1].attributes[2].nodeValue;
                    var ParamA_Log = nodes[2].attributes[0].nodeValue;
                    var ParamB_Log = nodes[2].attributes[1].nodeValue;
                    var ParamR_Log = nodes[2].attributes[2].nodeValue;
                    
                    var txtModelLine = "";
                    var txtModelExp = "";
                    var txtModelLn = "";
                    
                    if(ParamB_Liner >= 0)
                    {  txtModelLine = "Y = " + ParamA_Liner + "+" + ParamB_Liner+ "*X";  }
                    else
                    {  txtModelLine = "Y = " + ParamA_Liner + "" + ParamB_Liner+ "*X";  }
                    $("#txtLine").val(txtModelLine);
                    $("#txtLineR").val(ParamR_Liner);
                    if(ParamB_Exp >= 0)
                    {  txtModelExp = "Y = " + ParamA_Exp + "+" + ParamB_Exp + "*Exp(X)";  }
                    else
                    {  txtModelExp = "Y = " + ParamA_Exp + "" + ParamB_Exp + "*Exp(X)";  }
                    $("#txtExp").val(txtModelExp);
                    $("#txtExpR").val(ParamR_Exp);
                    if(ParamB_Log >= 0)
                    {  txtModelLn = "Y = " + ParamA_Log + "+" + ParamB_Log + "*Ln(X)"; }
                    else
                    {  txtModelLn = "Y = " + ParamA_Log + "" + ParamB_Log + "*Ln(X)";  }                    
                    $("#txtLn").val(txtModelLn);
                    $("#txtLnR").val(ParamR_Log);
                 });
}


//********************灾害监测--旱情**************
//提取旱情指数
function calculateRSIndex_Drought()
{
    var imageId = $("#ImageListSelect").val();
    var blockSize = $("#BlockSizeSelect").val();
    
    if(gMapListen)
    {
        removeListener();
    }

    document.getElementById("mdiv").style.visibility="hidden";
    
    showWaitImage();

     var strURL = "services/getRSIndex_Drought.aspx";
     $.get(strURL,{ IMAGEID:imageId,
                    BLOCKSIZE:blockSize,
                    TMP:Math.random()
                  },
                  function(data){ 
         var xmlDocument = data.documentElement;
         var nodes = xmlDocument.getElementsByTagName("Parcel");
         var pointNumber = nodes.length;
         
         if (pointNumber == 0){
            alert("遥感指数计算过程出错，请您检查网络连接或者重新计算！");
            return;
         }
         else
         {
             markerSampleRSPoints_Drought(xmlDocument);            
         }     
     
     });
}

